; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -S -passes=globalopt < %s | FileCheck %s

; In this case an instruction queued for recursive deletion gets RAUWd with
; a constant in the meantime. Make sure this does not cause an assertion
; failure.

@a = internal global ptr null
@b = internal global ptr @a

define void @test() {
; CHECK-LABEL: @test(
; CHECK-NEXT:    ret void
;
  %v1 = load ptr, ptr @b
  %v2 = load ptr, ptr %v1
  store ptr %v2, ptr @a
  ret void
}

